import axios from '@/libs/api.request'

export const addDeploy = (data) => {
  return axios.request({
    url: 'deploy/manage/',
    data,
    method: 'post'
  })
}

export const deployBuildOrLogs = (id, params) => {
  return axios.request({
    url: `deploy/opraion/${id}`,
    params,
    method: 'get'
  })
}

export const deployAllSearch = (env, appType, searchValue) => {
  const params = {
    'env': env,
    'application_type': appType,
    'search': searchValue
  }
  return axios.request({
    url: 'deploy/manage/',
    params,
    method: 'get'
  })
}

export const deployList = (env, appType, page, pageSize, searchValue) => {
  const params = {
    'env': env,
    'application_type': appType,
    'Page': page,
    'PageSize': pageSize,
    'search': searchValue
  }
  return axios.request({
    url: 'deploy/manage/',
    params,
    method: 'get'
  })
}

export const deleteDeploy = (id) => {
  return axios.request({
    url: `deploy/manage/${id}/`,
    method: 'delete'
  })
}

export const updateDeploy = (id, data) => {
  return axios.request({
    url: `deploy/manage/${id}/`,
    data,
    method: 'patch'
  })
}

export const projectList = (env, appType) => {
  const params = {
    'env': env,
    'application_type': appType
  }
  return axios.request({
    url: 'deploy/projectNameList/',
    params,
    method: 'get'
  })
}

export const historyDeployList = (env, appType, name) => {
  const params = {
    'env': env,
    'application_type': appType,
    'name': name
  }
  return axios.request({
    url: 'deploy/history/',
    params,
    method: 'get'
  })
}

export const projectHistoryDeploy = (id) => {
  return axios.request({
    url: `deploy/history/${id}/`,
    method: 'get'
  })
}

export const deployConfTypeCreate = (data) => {
  return axios.request({
    url: '/deploy/type/',
    data,
    method: 'post'
  })
}

export const deployConfTypeUpdate = (id, data) => {
  return axios.request({
    url: `/deploy/type/${id}/`,
    data,
    method: 'patch'
  })
}

export const deployConfTypeDetail = () => {
  return axios.request({
    url: '/deploy/type/',
    method: 'get'
  })
}

export const deployConfTypeDelete = (id) => {
  return axios.request({
    url: `/deploy/type/${id}/`,
    method: 'delete'
  })
}

export const deployConfEnvsCreate = (data) => {
  return axios.request({
    url: '/deploy/envs/',
    data,
    method: 'post'
  })
}

export const deployConfEnvsDetail = () => {
  return axios.request({
    url: '/deploy/envs/',
    method: 'get'
  })
}

export const deployConfEnvsDelete = (id) => {
  return axios.request({
    url: `/deploy/envs/${id}/`,
    method: 'delete'
  })
}
